/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server1;

import game.Spiel;
import java.io.ObjectInputStream;
import java.net.Socket;

/**
 *
 * @author timbeer
 */
public class ServerThread extends Thread {

    private Server server;
    private Socket client;

    public ServerThread(Server server, Socket client) {

        this.server = server;
        this.client = client;

        start();
    }

    public void run() {
        try {
            ObjectInputStream ois = new ObjectInputStream(client.getInputStream());

            while (true) {

                //read object
                Spiel spiel = (Spiel) ois.readObject();

                System.out.println("Object read...");

                server.sendToAll(spiel);

            }
        } catch (Exception e) {
            System.out.println(e.toString());
        }

    }
}
